support using cron expressions for timestamps #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pr will allow some very powerful schedules based on a cron timer. It is only a PoC and if interested I will also adjust the tests to run properly.
It only supports basic crons (with numbers) for performance / gas reasons.
It uses chrono (https://github.com/chronotope/chrono) to convert a unix timestamp to a datetime with components to start the search and convert the result back)
For the search structure the tm structure has been copied: https://docs.rs/mysql/14.0.0/mysql/time/struct.Tm.html
The implementation is based on https://crates.io/crates/crontab with adjustments for weekday support.
This is the major difference to normal cron, that weekdays are complimentary to all other options, which is a lot more sane in my opinion than in the normal implementation. It allows for powerful options like recurring jobs executing exactly first monday of a month (what we will need for our amp governance tune+redelegation)
There is this for blockchains optimized version: https://github.com/CronCats/Schedule
It is a bit more powerful, but not as lightweight as what could be enough for warp.
I feel like the used version is a very clean, straight forward and performant implementation. That is why I always prefer direct integrations for dependencies. Not sure about chrono, but it seems it is okay to run on the chain.
Usage is quite similar to the example in #15